package com.example.demo;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class Test {


    public static void main(String[] args) throws ExecutionException, InterruptedException, TimeoutException {
        FutureTask xxx = new FutureTask(() -> {
            System.out.println("xxx");
            Thread.sleep(1000);
            return 1;
        });
        xxx.run();
        Object o = xxx.get(2, TimeUnit.SECONDS);
        System.out.println("o="+o);
    }
}
